
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Javascript Optimization · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="local application.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    前端进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Grid System.html">
            
                <a href="Grid System.html">
            
                    
                    Grid System
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="Handwritten signature.html">
            
                <a href="Handwritten signature.html">
            
                    
                    Handwritten Signature
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Mobile Soft Keyboard.html">
            
                <a href="Mobile Soft Keyboard.html">
            
                    
                    Mobile Soft Keyboard
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="authentication.html">
            
                <a href="authentication.html">
            
                    
                    Authentication
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Code
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" >
            
                <span>
            
                    
                    Four Operations
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="control loading.html">
            
                <a href="control loading.html">
            
                    
                    Control Loading
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="downfile.html">
            
                <a href="downfile.html">
            
                    
                    Downfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="dynamic-routing.html">
            
                <a href="dynamic-routing.html">
            
                    
                    Dynamic Routing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="ecs.html">
            
                <a href="ecs.html">
            
                    
                    Ecs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="engineering.html">
            
                <a href="engineering.html">
            
                    
                    Engineering
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="eslint-vscode-format.html">
            
                <a href="eslint-vscode-format.html">
            
                    
                    Eslint Vscode Format
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="eventloop.html">
            
                <a href="eventloop.html">
            
                    
                    Eventloop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="four-operations-1.html">
            
                <a href="four-operations-1.html">
            
                    
                    Four Operations 1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="four-operations-2.html">
            
                <a href="four-operations-2.html">
            
                    
                    Four Operations 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="four-operations-3.html">
            
                <a href="four-operations-3.html">
            
                    
                    Four Operations 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="four-operations-4.html">
            
                <a href="four-operations-4.html">
            
                    
                    Four Operations 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="front end summary.html">
            
                <a href="front end summary.html">
            
                    
                    Front End Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="git commit style.html">
            
                <a href="git commit style.html">
            
                    
                    Git Commit Style
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="git-commands.html">
            
                <a href="git-commands.html">
            
                    
                    Git Commands
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="high-quality-code.html">
            
                <a href="high-quality-code.html">
            
                    
                    High Quality Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="history.html">
            
                <a href="history.html">
            
                    
                    History
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="html-tag.html">
            
                <a href="html-tag.html">
            
                    
                    Html Tag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="http-https-http2.html">
            
                <a href="http-https-http2.html">
            
                    
                    Http Https Http2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ignore log.html">
            
                <a href="ignore log.html">
            
                    
                    Ignore Log
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" >
            
                <span>
            
                    
                    Imgs
            
                </span>
            

            
        </li>
    
        <li class="chapter active" data-level="1.28" data-path="javascript-optimization.html">
            
                <a href="javascript-optimization.html">
            
                    
                    Javascript Optimization
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.29" data-path="local application.html">
            
                <a href="local application.html">
            
                    
                    Local Application
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.30" data-path="locality.html">
            
                <a href="locality.html">
            
                    
                    Locality
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.31" data-path="loop-unrolling.html">
            
                <a href="loop-unrolling.html">
            
                    
                    Loop Unrolling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.32" data-path="mobile recommendation.html">
            
                <a href="mobile recommendation.html">
            
                    
                    Mobile Recommendation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.33" data-path="modal.html">
            
                <a href="modal.html">
            
                    
                    Modal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.34" data-path="monitor.html">
            
                <a href="monitor.html">
            
                    
                    Monitor
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.35" data-path="performance.html">
            
                <a href="performance.html">
            
                    
                    Performance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.36" data-path="print-talbe.html">
            
                <a href="print-talbe.html">
            
                    
                    Print Talbe
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.37" data-path="promise.html">
            
                <a href="promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.38" data-path="teaching.html">
            
                <a href="teaching.html">
            
                    
                    Teaching
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.39" data-path="vue refresh.html">
            
                <a href="vue refresh.html">
            
                    
                    Vue Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.40" data-path="vue-page-not-refresh.html">
            
                <a href="vue-page-not-refresh.html">
            
                    
                    Vue Page Not Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.41" data-path="why-learn-theory.html">
            
                <a href="why-learn-theory.html">
            
                    
                    Why Learn Theory
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Javascript Optimization</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="javascript-&#x6027;&#x80FD;&#x4F18;&#x5316;">JavaScript &#x6027;&#x80FD;&#x4F18;&#x5316;</h1>
<h2 id="&#x52A0;&#x8F7D;&#x4E0E;&#x6267;&#x884C;">&#x52A0;&#x8F7D;&#x4E0E;&#x6267;&#x884C;</h2>
<ul>
<li>&#x5C06;<code>&lt;script&gt;</code>&#x6807;&#x7B7E;&#x653E;&#x5728;<code>&lt;/body&gt;</code>&#x524D;&#x9762;&#xFF0C;&#x4E0D;&#x8981;&#x653E;&#x5728;<code>&lt;head&gt;</code>&#x4E2D;&#xFF0C;&#x9632;&#x6B62;&#x9020;&#x6210;&#x5835;&#x585E;</li>
<li>&#x5C3D;&#x91CF;&#x51CF;&#x5C11;&#x8BF7;&#x6C42;&#xFF0C;&#x5355;&#x4E2A;100KB&#x7684;&#x6587;&#x4EF6;&#x6BD4;4&#x4E2A;25KB&#x7684;&#x6587;&#x4EF6;&#x66F4;&#x5FEB;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x51CF;&#x5C11;&#x9875;&#x9762;&#x4E2D;&#x5916;&#x94FE;&#x7684;&#x6587;&#x4EF6;&#x4F1A;&#x6539;&#x5584;&#x6027;&#x80FD;</li>
<li>&#x5C3D;&#x91CF;&#x4F7F;&#x7528;&#x538B;&#x7F29;&#x8FC7;&#x7684;JS&#x6587;&#x4EF6;&#xFF0C;&#x4F53;&#x79EF;&#x66F4;&#x5C0F;&#xFF0C;&#x52A0;&#x8F7D;&#x66F4;&#x5FEB;</li>
</ul>
<h2 id="&#x6570;&#x636E;&#x5B58;&#x53D6;">&#x6570;&#x636E;&#x5B58;&#x53D6;</h2>
<ul>
<li>&#x4F7F;&#x7528;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x548C;&#x5B57;&#x9762;&#x91CF;&#x6BD4;&#x4F7F;&#x7528;&#x6570;&#x7EC4;&#x548C;&#x5BF9;&#x8C61;&#x6709;&#x66F4;&#x5C11;&#x7684;&#x8BFB;&#x5199;&#x6D88;&#x8017;</li>
<li>&#x5C3D;&#x53EF;&#x80FD;&#x4F7F;&#x7528;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x4EE3;&#x66FF;&#x5168;&#x5C40;&#x53D8;&#x91CF;</li>
<li>&#x5982;&#x65E0;&#x5FC5;&#x8981;&#xFF0C;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x95ED;&#x5305;&#xFF1B;&#x95ED;&#x5305;&#x5F15;&#x7528;&#x7740;&#x5176;&#x4ED6;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x4F1A;&#x9020;&#x6210;&#x66F4;&#x5927;&#x7684;&#x5185;&#x5B58;&#x5F00;&#x9500;</li>
<li>&#x539F;&#x578B;&#x94FE;&#x4E0D;&#x8981;&#x8FC7;&#x6DF1;&#x3001;&#x5BF9;&#x8C61;&#x5D4C;&#x5957;&#x4E0D;&#x8981;&#x592A;&#x591A;</li>
<li>&#x5BF9;&#x4E8E;&#x591A;&#x6B21;&#x8BBF;&#x95EE;&#x7684;&#x5D4C;&#x5957;&#x5BF9;&#x8C61;&#xFF0C;&#x5E94;&#x8BE5;&#x7528;&#x53D8;&#x91CF;&#x7F13;&#x5B58;&#x8D77;&#x6765;</li>
</ul>
<h2 id="dom&#x7F16;&#x7A0B;">DOM&#x7F16;&#x7A0B;</h2>
<ul>
<li>&#x4E0D;&#x8981;&#x9891;&#x7E41;&#x4FEE;&#x6539;DOM&#xFF0C;&#x56E0;&#x4E3A;&#x4FEE;&#x6539;DOM&#x6837;&#x5F0F;&#x4F1A;&#x5BFC;&#x81F4;&#x91CD;&#x7ED8;(repaint)&#x548C;&#x91CD;&#x6392;(reflow)</li>
<li>&#x5982;&#x679C;&#x8981;&#x4FEE;&#x6539;DOM&#x7684;&#x591A;&#x4E2A;&#x6837;&#x5F0F;&#x53EF;&#x4EE5;&#x7528;cssText&#x4E00;&#x6B21;&#x6027;&#x5C06;&#x8981;&#x6539;&#x7684;&#x6837;&#x5F0F;&#x5199;&#x5165;&#xFF0C;&#x6216;&#x5C06;&#x6837;&#x5F0F;&#x5199;&#x5230;class&#x91CC;&#xFF0C;&#x518D;&#x4FEE;&#x6539;DOM&#x7684;class&#x540D;&#x79F0;<pre><code>const el = document.querySelector(&apos;.myDiv&apos;)
el.style.borderLeft = &apos;1px&apos;
el.style.borderRight = &apos;2px&apos;
el.style.padding = &apos;5px&apos;
</code></pre>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x8BED;&#x53E5;&#x4EE3;&#x66FF;<pre><code>const el = document.querySelector(&apos;.myDiv&apos;)
el.style.cssText = &apos;border-left: 1px; border-right: 2px; padding: 5px;&apos;
</code></pre>cssText&#x4F1A;&#x8986;&#x76D6;&#x5DF2;&#x5B58;&#x5728;&#x7684;&#x6837;&#x5F0F;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x60F3;&#x8986;&#x76D6;&#x5DF2;&#x6709;&#x6837;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;<pre><code>el.style.cssText += &apos;;border-left: 1px; border-right: 2px; padding: 5px;&apos;
</code></pre></li>
<li>&#x907F;&#x514D;&#x5927;&#x91CF;&#x4F7F;&#x7528;<code>:hover</code></li>
<li>&#x4F7F;&#x7528;&#x4E8B;&#x4EF6;&#x59D4;&#x6258;
```<ul>
<li>&#x82F9;&#x679C;</li>
<li>&#x9999;&#x8549;</li>
<li>&#x51E4;&#x68A8;</li>
</ul>

</li>
</ul>
<p>// good
document.querySelector(&apos;ul&apos;).onclick = (event) =&gt; {
  let target = event.target
  if (target.nodeName === &apos;LI&apos;) {
    console.log(target.innerHTML)
  }
}</p>
<p>// bad
document.querySelectorAll(&apos;li&apos;).forEach((e) =&gt; {
  e.onclick = function() {
    console.log(this.innerHTML)
  }
}) </p>
<pre><code>
#### &#x6279;&#x91CF;&#x4FEE;&#x6539;DOM
&#x5F53;&#x4F60;&#x9700;&#x8981;&#x6279;&#x91CF;&#x4FEE;&#x6539;DOM&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x6B65;&#x9AA4;&#x51CF;&#x5C11;&#x91CD;&#x7ED8;&#x548C;&#x91CD;&#x6392;&#x6B21;&#x6570;&#xFF1A;
1. &#x4F7F;&#x5143;&#x7D20;&#x8131;&#x79BB;&#x6587;&#x6863;&#x6D41;
2. &#x5BF9;&#x5176;&#x5E94;&#x7528;&#x591A;&#x91CD;&#x6539;&#x53D8;
3. &#x628A;&#x5143;&#x7D20;&#x5E26;&#x56DE;&#x6587;&#x6863;&#x4E2D;

&#x8BE5;&#x8FC7;&#x7A0B;&#x4F1A;&#x89E6;&#x53D1;&#x4E24;&#x6B21;&#x91CD;&#x6392;&#x2014;&#x2014;&#x7B2C;&#x4E00;&#x6B65;&#x548C;&#x7B2C;&#x4E09;&#x6B65;&#x3002;&#x5982;&#x679C;&#x4F60;&#x5FFD;&#x7565;&#x8FD9;&#x4E24;&#x4E2A;&#x6B65;&#x9AA4;&#xFF0C;&#x90A3;&#x4E48;&#x5728;&#x7B2C;&#x4E8C;&#x6B65;&#x6240;&#x4EA7;&#x751F;&#x7684;&#x4EFB;&#x4F55;&#x4FEE;&#x6539;&#x90FD;&#x4F1A;&#x89E6;&#x53D1;&#x4E00;&#x6B21;&#x91CD;&#x6392;&#x3002;&lt;br&gt;
&#x6709;&#x4E09;&#x79CD;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x4F7F;DOM&#x8131;&#x79BB;&#x6587;&#x6863;&#xFF1A;
* &#x9690;&#x85CF;&#x5143;&#x7D20;&#xFF0C;&#x5E94;&#x7528;&#x4FEE;&#x6539;&#xFF0C;&#x91CD;&#x65B0;&#x663E;&#x793A;
* &#x4F7F;&#x7528;&#x6587;&#x6863;&#x7247;&#x65AD;&#xFF08;document.fragment&#xFF09;&#x5728;&#x5F53;&#x524D;DOM&#x4E4B;&#x5916;&#x6784;&#x5EFA;&#x4E00;&#x4E2A;&#x5B50;&#x6811;&#xFF0C;&#x518D;&#x628A;&#x5B83;&#x62F7;&#x56DE;&#x6587;&#x6863;
* &#x5C06;&#x539F;&#x59CB;&#x5143;&#x7D20;&#x62F7;&#x8D1D;&#x5230;&#x4E00;&#x4E2A;&#x8131;&#x79BB;&#x6587;&#x6863;&#x7684;&#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x4FEE;&#x6539;&#x526F;&#x672C;&#xFF0C;&#x5B8C;&#x6210;&#x540E;&#x518D;&#x66FF;&#x6362;&#x539F;&#x59CB;&#x5143;&#x7D20;

## &#x7B97;&#x6CD5;&#x548C;&#x6D41;&#x7A0B;&#x63A7;&#x5236;
* &#x6539;&#x5584;&#x6027;&#x80FD;&#x6700;&#x4F73;&#x7684;&#x65B9;&#x5F0F;&#x662F;&#x51CF;&#x5C11;&#x6BCF;&#x6B21;&#x8FED;&#x4EE3;&#x7684;&#x8FD0;&#x7B97;&#x91CF;&#x548C;&#x51CF;&#x5C11;&#x5FAA;&#x73AF;&#x8FED;&#x4EE3;&#x6B21;&#x6570;
* JavaScript&#x56DB;&#x79CD;&#x5FAA;&#x73AF;&#x4E2D;`for` `while` `do-while` `for-in`&#xFF0C;&#x53EA;&#x6709;`for-in`&#x5FAA;&#x73AF;&#x6BD4;&#x5176;&#x4ED6;&#x5176;&#x4E2D;&#x660E;&#x663E;&#x8981;&#x6162;&#xFF0C;&#x56E0;&#x4E3A;`for-in`&#x5FAA;&#x73AF;&#x8981;&#x641C;&#x7D22;&#x539F;&#x578B;&#x5C5E;&#x6027;
* &#x9650;&#x5236;&#x5FAA;&#x73AF;&#x4E2D;&#x8017;&#x65F6;&#x64CD;&#x4F5C;&#x7684;&#x6570;&#x91CF;
* &#x57FA;&#x4E8E;&#x51FD;&#x6570;&#x7684;&#x8FED;&#x4EE3;`forEach`&#x6BD4;&#x4E00;&#x822C;&#x7684;&#x5FAA;&#x73AF;&#x8981;&#x6162;&#xFF0C;&#x5982;&#x679C;&#x5BF9;&#x8FD0;&#x884C;&#x901F;&#x5EA6;&#x8981;&#x6C42;&#x5F88;&#x4E25;&#x683C;&#xFF0C;&#x4E0D;&#x8981;&#x4F7F;&#x7528;
* `if-else` `switch`&#xFF0C;&#x6761;&#x4EF6;&#x6570;&#x91CF;&#x8D8A;&#x5927;&#xFF0C;&#x8D8A;&#x503E;&#x5411;&#x4E8E;&#x4F7F;&#x7528;`switch`
* &#x5728;&#x5224;&#x65AD;&#x6761;&#x4EF6;&#x591A;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x67E5;&#x627E;&#x8868;&#x6765;&#x4EE3;&#x66FF;`if-else` `switch`&#xFF0C;&#x901F;&#x5EA6;&#x66F4;&#x5FEB;
</code></pre><p>switch(value) {
  case 0:
    return result0
    break
  case 1:
    return result1
    break
  case 2:
    return result2
    break
  case 3:
    return result3
    break</p>
<p>}</p>
<p>// &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x67E5;&#x627E;&#x8868;&#x4EE3;&#x66FF;
const results = [result0, result1, result2, result3]</p>
<pre><code>* &#x5982;&#x679C;&#x9047;&#x5230;&#x6808;&#x6EA2;&#x51FA;&#x9519;&#x8BEF;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FED;&#x4EE3;&#x6765;&#x4EE3;&#x66FF;&#x9012;&#x5F52;

## &#x5B57;&#x7B26;&#x4E32;
</code></pre><p>str += &apos;one&apos; + &apos;two&apos;</p>
<pre><code>&#x6B64;&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x65F6;&#xFF0C;&#x4F1A;&#x7ECF;&#x5386;&#x56DB;&#x4E2A;&#x6B65;&#x9AA4;&#xFF1A;
1. &#x5728;&#x5185;&#x5B58;&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x4E34;&#x65F6;&#x5B57;&#x7B26;&#x4E32;
2. &#x8FDE;&#x63A5;&#x540E;&#x7684;&#x5B57;&#x7B26;&#x4E32; `onetwo` &#x88AB;&#x8D4B;&#x503C;&#x7ED9;&#x8BE5;&#x4E34;&#x65F6;&#x5B57;&#x7B26;&#x4E32;
3. &#x4E34;&#x65F6;&#x5B57;&#x7B26;&#x4E32;&#x4E0E;str&#x5F53;&#x524D;&#x7684;&#x503C;&#x8FDE;&#x63A5;
4. &#x7ED3;&#x679C;&#x8D4B;&#x503C;&#x7ED9;str
</code></pre><p>str += &apos;one&apos; 
str += &apos;two&apos;</p>
<pre><code>&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x5F0F;&#x6BD4;&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x8981;&#x66F4;&#x5FEB;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x907F;&#x514D;&#x4E86;&#x4E34;&#x65F6;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x4EA7;&#x751F;&lt;br&gt;

&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x4E00;&#x4E2A;&#x8BED;&#x53E5;&#x5C31;&#x80FD;&#x8FBE;&#x5230;&#x540C;&#x6837;&#x7684;&#x6027;&#x80FD;&#x63D0;&#x5347;
</code></pre><p>str = str + &apos;one&apos; + &apos;two&apos;</p>
<pre><code>
## &#x5FEB;&#x901F;&#x54CD;&#x5E94;&#x7528;&#x6237;&#x754C;&#x9762;
* &#x5BF9;&#x4E8E;&#x6267;&#x884C;&#x65F6;&#x95F4;&#x8FC7;&#x957F;&#x7684;&#x5927;&#x6BB5;&#x4EE3;&#x7801;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;`setTimeout`&#x548C;`setInterval`&#x6765;&#x5BF9;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x5206;&#x5272;&#xFF0C;&#x907F;&#x514D;&#x5BF9;&#x9875;&#x9762;&#x9020;&#x6210;&#x5835;&#x585E;
* &#x5BF9;&#x4E8E;&#x6570;&#x636E;&#x5904;&#x7406;&#x5DE5;&#x4F5C;&#x53EF;&#x4EE5;&#x4EA4;&#x7531;`Web Workers`&#x6765;&#x5904;&#x7406;&#xFF0C;&#x56E0;&#x4E3A;`Web Workers`&#x4E0D;&#x5360;&#x7528;&#x6D4F;&#x89C8;&#x5668;UI&#x7EBF;&#x7A0B;&#x7684;&#x65F6;&#x95F4;

## &#x7F16;&#x7A0B;&#x5B9E;&#x8DF5;
* &#x4F7F;&#x7528;Object/Array&#x5B57;&#x9762;&#x91CF;
</code></pre><p>const obj = new Object()
const newObj = {}</p>
<p>const arry = new Array()
const newArry = []</p>
<pre><code>&#x4F7F;&#x7528;&#x5B57;&#x9762;&#x91CF;&#x4F1A;&#x8FD0;&#x884C;&#x5F97;&#x66F4;&#x5FEB;&#xFF0C;&#x5E76;&#x4E14;&#x8282;&#x7701;&#x4EE3;&#x7801;&#x91CF;
* &#x4F4D;&#x64CD;&#x4F5C;&#x5728;JavaScript&#x4E2D;&#x6027;&#x80FD;&#x975E;&#x5E38;&#x5FEB;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4F4D;&#x8FD0;&#x7B97;&#x6765;&#x4EE3;&#x66FF;&#x7EAF;&#x6570;&#x5B66;&#x64CD;&#x4F5C;
</code></pre><p>x =* x
// &#x7528;&#x4F4D;&#x8FD0;&#x7B97;&#x4EE3;&#x66FF; 
x &lt;&lt;= 1
```</p>
<ul>
<li>&#x5982;&#x65E0;&#x5FC5;&#x8981;&#xFF0C;&#x4E0D;&#x8981;&#x91CD;&#x5199;&#x539F;&#x751F;&#x65B9;&#x6CD5;&#xFF0C;&#x56E0;&#x4E3A;&#x539F;&#x751F;&#x65B9;&#x6CD5;&#x5E95;&#x5C42;&#x662F;&#x7528;C/C++&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x901F;&#x5EA6;&#x66F4;&#x5FEB;</li>
</ul>
<h3 id="&#x53C2;&#x8003;&#x8D44;&#x6599;">&#x53C2;&#x8003;&#x8D44;&#x6599;</h3>
<p><a href="https://book.douban.com/subject/26599677/" target="_blank">&#x9AD8;&#x6027;&#x80FD;JavaScript</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="local application.html" class="navigation navigation-next navigation-unique" aria-label="Next page: Local Application">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Javascript Optimization","level":"1.28","depth":1,"next":{"title":"Local Application","level":"1.29","depth":1,"path":"前端进阶/local application.md","ref":"前端进阶/local application.md","articles":[]},"previous":{"title":"Imgs","level":"1.27","depth":1,"ref":"","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["summary","livereload"],"pluginsConfig":{"summary":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"前端进阶/javascript-optimization.md","mtime":"2021-02-15T12:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-03-24T08:50:55.666Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

